﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Kevin.Controls
{
    public class DataBindItemCollectionPropertyDescriptor:PropertyDescriptor
    {
        private DataBindItemCollection collection = null;
        private int index = -1;

        public DataBindItemCollectionPropertyDescriptor(DataBindItemCollection coll,int idx):base( "#"+idx.ToString(), null )
        {
            collection = coll;
            index = idx;
        }

        #region PropertyDescriptor members

        public override bool CanResetValue(object component)
        {
            return true;
        }

        public override Type ComponentType
        {
            get
            {
                return this.collection.GetType();
            }
        }

        public override object GetValue(object component)
        {
            return this.collection[index];
        }

        public override bool IsReadOnly
        {
            get { return false; }
        }

        public override Type PropertyType
        {
            get
            {
                return this.collection[index].GetType();
            }
        }

        public override void ResetValue(object component)
        {
           // throw new NotImplementedException();
        }

        public override void SetValue(object component, object value)
        {
           
        }

        public override bool ShouldSerializeValue(object component)
        {
            return true;
        }

        public override string Description
        {
            get
            {
                return "";
                return base.Description;
            }
        }

        #endregion
    }
}
